package 设计模式.创建型模式.demo05单例模式;

/**
 * @author: 王富贵
 * @description: 双检锁，线程安全的饿汉式
 * @createTime: 2022/11/07 16:52
 */
public class DoubleCheckLockSingle {
    private static volatile DoubleCheckLockSingle instance = null;

    private DoubleCheckLockSingle(){}

    public DoubleCheckLockSingle getInstance(){
        if (instance == null){
            synchronized (DoubleCheckLockSingle.class){
                if (instance == null){
                    instance = new DoubleCheckLockSingle();
                }
            }
        }
        return instance;
    }
}
